package com.noreply.springannotation.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;

import java.util.Arrays;

/**
 * @author noreply
 * @description
 */
@Aspect
public class LogAspect {
    @Pointcut("execution(public int com.noreply.springannotation.aop.MathCalculator.*(..))")
    public void pointCut() {

    }

    @Before("pointCut()")
    public void logStart(JoinPoint joinPoint) {
        Object args = joinPoint.getArgs();
        System.out.println(joinPoint.getSignature() +  "start...{" + Arrays.asList(args).toString() + "}");
    }

    @After("pointCut()")
    public void logEnd() {
        System.out.println("end...");
    }

    @AfterThrowing("pointCut()")
    public void logException() {
        System.out.println("exception...{}");
    }

    @AfterReturning("pointCut()")
    public void logReturn() {
        System.out.println("return...{}");
    }

}
